//
//  ByFoundVC.m
//  caipiao_ios
//
//  Created by mc on 2018/7/3.
//  Copyright © 2018年 ZhangZhanbin. All rights reserved.
//

#import "ByFoundVC.h"
#import "ByPlayLIstVC.h"
#import "ByNewsListVC.h"
#import "ByNoticeListVC.h"
@interface ByFoundVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;



@end

@implementation ByFoundVC




- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"发现";
    [self initViews];
    // Do any additional setup after loading the view.
}

- (void)initViews{
    
    self.view.backgroundColor = BY_BACKGROUND_COLOR;
    self.tableView = [[UITableView alloc] init];
    self.tableView.backgroundColor = BY_BACKGROUND_COLOR;
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(0);
        make.right.equalTo(self.view).offset(0);
       
        if (@available(ios 11.0,*)) {
            make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop).offset(0);
            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(-49);
        } else {
            make.top.equalTo(self.view).offset(0);
            make.bottom.equalTo(self.view).offset(-49);
        }
    }];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    
    
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifier = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        cell.contentView.backgroundColor = BY_BACKGROUND_COLOR;
     
    }
    for (UIView *view in cell.contentView.subviews) {
        [view removeFromSuperview];
    }
    
    UIView *backgroundView = [[UIView alloc] init];
    [cell.contentView addSubview:backgroundView];
    [backgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(cell.contentView).offset(7);
        make.right.equalTo(cell.contentView).offset(-7);
        make.bottom.equalTo(cell.contentView).offset(-5);
        make.top.equalTo(cell.contentView).offset(0);
    }];
    backgroundView.layer.cornerRadius = 10;
    backgroundView.backgroundColor = [UIColor whiteColor];
    
    UIImageView *iconView = [[UIImageView alloc] init];
    [backgroundView addSubview:iconView];
    [iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(backgroundView).offset(10);
        make.centerY.equalTo(backgroundView).offset(0);
        make.size.mas_equalTo(CGSizeMake(50, 50));
    }];
    
    

    
    UILabel *titleLabel = [[UILabel alloc] init];
    [backgroundView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(iconView.mas_right).offset(10);
        make.top.equalTo(iconView.mas_top).offset(5);
        make.height.mas_equalTo(@20);
        make.right.equalTo(backgroundView).offset(-100);
    }];
    
    titleLabel.font = FONT(14);
    titleLabel.textColor = [UIColor blackColor];
    titleLabel.textAlignment = NSTextAlignmentLeft;
    
    NSArray *titlesAry = @[@"玩法大集",@"新闻资讯",@"活动中心",@"公告中心"];
    titleLabel.text = titlesAry[indexPath.row];
    
    NSArray *imagesAry =  @[@"wanfadaji玩法大集",@"xinweizixun新闻资讯",@"huodongzhongxin活动中心",@"gonggaozhongxin"];
    iconView.image = [UIImage imageNamed:imagesAry[indexPath.row]];
    
    
    UILabel *titleLabel1 = [[UILabel alloc] init];
    [backgroundView addSubview:titleLabel1];
    [titleLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(titleLabel.mas_left).offset(0);
        make.top.equalTo(titleLabel.mas_bottom).offset(0);
        make.height.mas_equalTo(@20);
        make.right.equalTo(titleLabel1.mas_right).offset(0);
    }];
    titleLabel1.font = FONT(12);
    titleLabel1.textColor = [UIColor lightGrayColor];
    titleLabel1.textAlignment = NSTextAlignmentLeft;
    titleLabel1.text = titlesAry[indexPath.row];
    
    UIImageView *arrowView = [[UIImageView alloc] init];
    [backgroundView addSubview:arrowView];
    [arrowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(backgroundView).offset(-10);
        make.centerY.equalTo(backgroundView).offset(0);
        make.size.mas_equalTo(CGSizeMake(15, 15));
    }];
    arrowView.image = [UIImage imageNamed:@"youjiantou1111"];
    
    return cell;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 75;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        ByPlayLIstVC *vc = [[ByPlayLIstVC alloc] init];
        vc.isPlayList = YES;
        [self by_normalPush:vc hasNavi:YES];
    }else if (indexPath.row == 1){
        ByNewsListVC *vc = [[ByNewsListVC alloc] init];
        [self by_normalPush:vc hasNavi:YES];
    }else if (indexPath.row == 3){
        ByNoticeListVC *vc = [[ByNoticeListVC alloc] init];
        [self by_normalPush:vc hasNavi:YES];
    }else if (indexPath.row == 2){
        ByPlayLIstVC *vc = [[ByPlayLIstVC alloc] init];
        vc.isPlayList = NO;
        [self by_normalPush:vc hasNavi:YES];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
